package com.example.demo.app2;

import org.apache.ibatis.javassist.Loader;
import org.springframework.beans.factory.CannotLoadBeanClassException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

@Controller
@ResponseBody
public class App2Controller {

    @Autowired
    App2Service  app2Service;

    @GetMapping("/app2")
    public List<HashMap> app2(String no,String date) {


        Date from = null;
        Date to = null;
        Calendar c = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        try {
            Date n = sdf.parse(date);
            c.setTime(n);
            c.set(Calendar.HOUR_OF_DAY, 7);
            from = c.getTime();
            c.add(Calendar.DATE,1);
            to = c.getTime();
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }


        return app2Service.app2(no, from, to);
    }
}
